package com.heatup.apt.common.dao;

import com.baomidou.mybatisplus.mapper.AutoMapper;
import com.heatup.apt.model.course.CourseSchedule;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

/**
 *
 * CourseSchedule 表数据库控制层接口
 *
 */
@Component
public interface CourseScheduleMapper extends AutoMapper<CourseSchedule> {

    /**
     * 根据课程ID删除课程时间关联信息
     * @param courseId
     * @return
     */
    @Delete({
            "delete from course_schedule",
            "where course_id = #{id,jdbcType=INTEGER}"
    })
    int deleteByCourseId(Integer courseId);

    @Select({
            "select",
            "id, course_id, duration, start_time, end_time, hour_min, week, weeks, periods, ",
            "weekly",
            "from course_schedule",
            "where course_id = #{course_id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    CourseSchedule selectByCourseId(Integer course_id);
}